//不使用vue加载首页需要seo的数据
// jQuery(function () {
//     var shop=jQuery("#notice_news").attr("theShop");
//     new Vue({
//         el:'#hotKeyWord',
//         data:{
//             productHotKeyWordsList:[],
//             brandHotKeyWordsList:[]
//         },
//         mounted: function () {
//             this.$nextTick(function () {
//                 this.getHotKeyWordsList(shop);
//             })
//         },
//         methods:{
//             getHotKeyWordsList:function (shop) {
//                 var that = this;
//                 that.productHotKeyWordsList=[];
//                 that.brandHotKeyWordsList =[];
//                 if(shop==undefined||shop==null){
//                     shop=1
//                 }
//                 that.$http.get('/indexShop/getHotKeyWordsList?shop='+shop).then(function (res) {
//                     if(res.body.stateCode==1){
//                         that.productHotKeyWordsList =res.body.data.productHotKeyWordsList;
//                         that.brandHotKeyWordsList =res.body.data.brandHotKeyWordsList;
//                     }
//
//                 })
//             }
//         }
//
//     });
//
// });

jQuery(function () {
    var cartItemCount=jQuery("#head_cartItemCount").val();
    if(cartItemCount===undefined){
        return;
    }
    jQuery.ajax({
        url: basePath+'/getMemCartCount',
        type: 'GET',
        success: function (data) {
            var count=0;
            if(data!=null){
                count=data;
            }
            jQuery("#head_cartItemCount").html(count);
            jQuery("#member_cartItemCount").text(count);
            var shoppingCarCount=jQuery("#shoppingCarCount").val();
            if(shoppingCarCount===undefined){
                return;
            }
            jQuery("#shoppingCarCount").html(count);


        }
    })
    getNoticeNews();
    getWeekTopList();
});
//获取hz单周热卖商品
function  getWeekTopList() {
    var shopId=jQuery("#notice_news").attr("theShop");
    var womanHtml = "";
    var manHtml = "";
    var childHtml = "";
    var mallHtml = "";
    if(shopId==undefined||shopId!=1){
        return ;
    }
    jQuery.ajax({
        type: "get",
        async:true,
        url:"/indexHz/getWeekTopList?shopId="+ shopId,
        success: function(data){
            if(data!=undefined&&data!=""){
                var result =data.data;
                var hzWomanTop = result.hzWomanTop;
                var hzManTop = result.hzManTop;
                var zlChildTop = result.zlChildTop;
                var wlShoeTop = result.wlShoeTop;
                var mallList = result.mallList;

                womanHtml = getTemplate(womanHtml,hzWomanTop);
                jQuery("#hzWoman").append(womanHtml);

                manHtml = getTemplate(manHtml,hzManTop);
                jQuery("#hzMan").append(manHtml);

                childHtml = getTemplate(childHtml,zlChildTop);
                jQuery("#zlChild").append(childHtml);

                jQuery("#wlShoe").append(getTemplate("",wlShoeTop));

                for(var i=0; i<mallList.length;i++){
                    var mall = mallList[i];
                    mallHtml+='<li><div class="ptoImg">';
                    mallHtml+='<a  href="/mall-'+mall.mallId+'.html" target="_blank"><img src="'+mall.images+'" alt=""><div class="ptoTpSw">'+mall.mallName+'</div>';
                    mallHtml+='<div class="megBot" >';
                    mallHtml+='<div class="lstBot1"><span>入驻：<i>'+mall.brandCount+'</i>家</span><span>商品：<i>'+mall.productCount+'</i>款</span></div></a>';
                    mallHtml+='<div class="lstBot2"><span>'+mall.markName1+'</span><span>'+mall.markName2+'</span></div>';
                    mallHtml+='</div></li>';

                }
                jQuery("#hzMall").append(mallHtml)
                //轮播jquery
                jQuery('.sldPtoBox').each(function () {
                    jQuery(this).superSlider({
                        prevBtn: ".prev",//左按钮
                        nextBtn: ".next",//右按钮
                        listCont: ".rollMenu",//滚动列表外层
                        scrollWhere: "next",//自动滚动方向next,prev
                        delayTime: 3000,//自动轮播时间间隔
                        speed: 300,//滚动速度
                        amount: 5,//单次滚动数量
                        showNum: 5,//显示数量
                        autoPlay: false//自动播放
                    });
                })

            }
        }
    })


}

//生成同样格式的模板
function  getTemplate(html,list) {
    var maxLenth=list.length>6?6:list.length;
    for(var i=0; i<maxLenth;i++){
        if(i>5){
            break;
        }
        var item = list[i];
        html+="<li>" ;
        html+='<a href="/product-'+item.id+'.html" target="_blank"><img title="'+item.name+'" alt="'+item.name+'" src="'+item.images+'"><div class="cor333">'+item.name+'</div>' ;
        html+="</li>" ;

    }
    return html;
}

//获取首页公告
function getNoticeNews(){
    var shopId=jQuery("#notice_news").attr("theShop");
    if(shopId==undefined){
        return ;
    }
    jQuery.ajax({
        type: "get",
        async:true,
        url: "/noticeNews/getNoticeNewsByShopId?shopId="+ shopId,
        success: function(data){
            if(data!=undefined&&data!=""){
                var html = "";
                for(var i=0;i<data.length;i++){
                    var newsUrl = data[i].link;
                    var imgUrl=data[i].image;
                    if(newsUrl!=undefined&&imgUrl!=undefined){//显示公告信息
                        html+='<a href="'+newsUrl+'" target="_blank">';
                        html+='<img src=\"'+imgUrl+'\" /></a>';
                    }
                }
                if(html.length>0){
                    jQuery("#notice_news").append(html);
                    jQuery('div.imgbox').imgbox();
                    jQuery("#notice").show();
                }
            }

        }
    });


}
//xp系统提示
function isXp() {
    var userAgent = navigator.userAgent.toLowerCase();
    if (userAgent.indexOf("windows nt 5.1") > -1 || userAgent.indexOf("windows nt 5.2") > -1) {//xp
        return true;
    }
    return false;
}
function isChrome() {
    var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
    if (userAgent.indexOf("Chrome") > -1){
        return true;
    }
    return false;
}
function _mime(option, value) {
    var mimeTypes = navigator.mimeTypes;
    for (var mt in mimeTypes) {
        if (mimeTypes[mt][option] == value) {
            return true;
        }
    }
    return false;
}
function is360() {
    return _mime("type", "application/vnd.chromium.remoting-viewer");
}
jQuery(function () {
    if(isXp() && !(!is360()&&isChrome())){
        var content = "<div class=\"dl-container\" style='width:500px;height:280px;background:#fff;text-align: center;box-shadow:0px 2px 8px 0px rgba(0,0,0,0.1);-webkit-border-radius: 10px;-moz-border-radius: 10px;border-radius: 10px;font-family: \"Microsoft YaHei\";'>" +
            "<div class=\"dl-top\" style='height:50px;line-height: 50px;color: #fff;background:#ED9943;font-size:20px;-webkit-border-radius: 10px 10px 0 0;-moz-border-radius: 10px 10px 0 0;border-radius: 10px 10px 0 0;'>- 温馨提示 -</div>" +
            "<div class=\"dl-cnt\" style='width: 300px;font-size:18px;color: #333333;margin: 30px auto 0;line-height:28px;'>检测到您使用的Windows XP系统与当前浏览器不支持TLS1.2协议，存在严重安全风险，请更换谷歌浏览器！</div>\n" +
            "  <div class=\"dl-btn\" style='margin-top: 50px;'>" +
            "<a href=\"http://video.hznzcn.com/plugins/chromesetup.exe\" style='width:180px;height:40px;line-height: 40px;color: #fff;font-size:16px;background:#ED9943;-webkit-border-radius: 30px;-moz-border-radius: 30px;border-radius: 30px;display: inline-block;margin-right: 17px;font-weight: 600;border:1px solid #ED9943;'>立即更换</a>" +
            "</div>" +
            "</div>";
        layer.open({
            type: 1,
            title: '',
            area: ['500px', '280px'],
            shadeClose: true, //点击遮罩关闭
            content: content
        });
    }
});
//gio统计
!function (e, t, n, g, i) {
    e[i] = e[i] || function () {
        (e[i].q = e[i].q || []).push(arguments)
    }, n = t.createElement("script"), tag = t.getElementsByTagName("script")[0], n.async = 1, n.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + g, tag.parentNode.insertBefore(n, tag)
}(window, document, "script", "assets.growingio.com/2.1/gio.js", "gio");
gio('init', 'a7f0bc16e8df64c1', {});
gio('send');

